package com.qfmy.controller.assistant;

import com.qfmy.service.assistant.VideoService;
import common.result.Result;
import jakarta.annotation.Resource;
import model.entity.assistant.AiVideo;
import model.query.VideoQuery;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.controller.assistant
 * @date 2025/5/19
 * @description 视频生成
 */
@RestController
@SuppressWarnings("all")
@RequestMapping("/app/video")
public class VideoController {

    /**
     * 注入service
     */
    @Resource
    private VideoService videoService;

    /**
     * 视频生成
     */
    @PostMapping("/textVideo")
    public Result<String> getVideoBytext(@RequestBody VideoQuery query) {
        String video = videoService.getVideoBytext(query);
        return Result.ok(video);
    }

    /**
     * 图生视频
     */
    @PostMapping("/imgVideo")
    public Result<String> getVideoByImg(@RequestBody VideoQuery query) {
        String video = videoService.getVideoByImg(query);
        return Result.ok(video);
    }

    /**
     * 根据时间获取用户生成的视频的次数
     */
    @RequestMapping("/getVideoCountByTime")
    public Result getVideoCountByTime(@RequestParam String time){
        Integer count =  videoService.getVideoCountByTime(time);
        return Result.ok(count);
    }

    /**
     * 获取所有的生成的视频
     */
    @RequestMapping("/getAllVideo")
    public Result getAllVideo(){
        List<AiVideo> aiVideoList = videoService.getAllVideo();
        return Result.ok(aiVideoList);
    }

    /**
     * 根据id删除生成的视频
     */
    @RequestMapping("/deleteVideoById")
    public Result deleteVideoById(@RequestParam Integer id){
        videoService.deleteVideoById(id);
        return Result.ok();
    }

    /**
     * 分页获取所有的生成的视频
     */
    @RequestMapping("/getVideoByPage")
    public Result getVideoByPage(@RequestBody VideoQuery query){
        List<AiVideo> aiVideoList = videoService.getVideoByPage(query);
        return Result.ok(aiVideoList);
    }

}
